//
//  PoliceCell.m
//  Manage
//
//  Created by 杨康 on 2017/11/10.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "PoliceCell.h"

@implementation PoliceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //        self.selectionStyle=UITableViewCellSelectionStyleNone;
        
        self.imgView=[[UIImageView alloc]init];
        //可省略
        self.imgView.layer.masksToBounds=YES;
        self.imgView.layer.cornerRadius=12.0;
        //
        [self.contentView addSubview:self.imgView];
        
        
        
        self.textLab=[[UILabel alloc]init];
        
        self.textLab.font=[UIFont systemFontOfSize:13];
        self.textLab.textColor=[UIColor color3];
        [self.contentView addSubview:self.textLab];
        
        
        
        self.detailTextLab=[[UILabel alloc]init];
        self.detailTextLab.font=[UIFont systemFontOfSize:12];
        self.detailTextLab.textColor=[UIColor color9];
        [self.contentView addSubview:self.detailTextLab];
        
        
        
        
        
        
        
        self.lineLab=[[UILabel alloc]init];
        self.lineLab.backgroundColor=[UIColor colorF];
        [self.contentView addSubview:self.lineLab];
        
        
        
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.contentView);
        //可省略
        make.size.mas_equalTo(CGSizeMake(24, 24));
        
    }];
    
    
    [self.textLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.left.mas_equalTo(self.imgView.mas_right).mas_offset(5);
        
    }];
    
    
    [self.detailTextLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.textLab);
        make.bottom.mas_equalTo(-8);
    }];
    
    
    
    
    [self.lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(-0.5);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 0.5));
    }];
    
    
}
-(void)setDataDic:(policeData *)dataDic
{
    
//    self.imgView.image =[UIImage imageNamed:dataDic.image?dataDic.image:@""];
    
    NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@/media%@", APPBaseUrl, dataDic.image]];
    UIImage *deImage=[UIImage imageNamed:@"默认头像"];
    
    if ([NSString isNULLString:dataDic.image]) {
        self.imgView.image=deImage;
        NSLog(@"默认图片");
    }
    else
    {
        
        [self.imgView sd_setImageWithURL:url placeholderImage:deImage options:SDWebImageRefreshCached];
        NSLog(@"网络图片");
    }
    
    
    self.textLab.text=[NSString stringWithFormat:@"昵称：%@",dataDic.name?dataDic.name:@""];
    self.detailTextLab.text=dataDic.phone?dataDic.phone:@"";
    
    _dataDic=dataDic;
}
@end
